import Vue from "vue";
import VueRouter from "vue-router";
// import { component } from "vue/types/umd";

Vue.use(VueRouter);

const routes = [
  {
    path: "/2",
    name: "ccco",
    component: () => import("../views/ccco.vue"),
  },
  {
    path: "/userhome/:id",
    name: "userhome",
    props: true,
    component: () => import("../views/userhome.vue"),
  },
  {
    path: "/singerdetails/:id",
    name: "singerdetails",
    props: true,
    component: () => import("../views/singerDetails.vue"),
  },
  {
    path: "/musiclistdetails/:id",
    props: true,
    name: "musiclistdetails",
    component: () => import("../views/musicListDetails.vue"),
  },
  {
    path: "/myMusic",
    name: "WnmyMusic",
    component: () => import("../views/WnmyMusic.vue"),
  },
  {
    path: "/newcd/:area",
    name: "newcd",
    props: true,
    component: () => import("../views/NewCD.vue"),
  },
  {
    path: "/songclient",
    name: "LjlDownloadClientPort",
    component: () => import("../views/LjlDownloadClientPort.vue"),
  },
  {
    path: "/singer",
    name: "wnsiger",
    component: () => import("../views/WnSinger.vue"),
    // props: true,
  },
  {
    path: "/search/:keywords?",
    props: true,
    name: "search",
    component: () => import("../views/search.vue"),
    // redirect: '/search/searchsong',
    children: [
      {
        path: "searchsong",
        name: "searchsong",
        props: true,
        component: () => import("../views/search/searchSong.vue"),
      },
      {
        path: "searchsinger",
        name: "searchsinger",
        props: true,
        component: () => import("../views/search/searchSinger.vue"),
      },
      {
        path: "searchplay",
        name: "searchplay",
        props: true,
        component: () => import("../views/search/searchPlay.vue"),
      },
      {
        path: "searchlist",
        name: "searchlist",
        props: true,
        component: () => import("../views/search/searchList.vue"),
      },
    ],
  },
  {
    path: "/rankinglist",
    name: "wnrankinglist",
    component: () => import("../views/WnRankingList.vue"),
  },
  // {
  //   path: "/rankinglist",
  //   name: "rankinglist",
  //   component: () => import("../views/RankingList.vue"),
  // },
  {
    path: "/1",
    name: "wnmusicbar",
    component: () => import("../views/Wnyinyuebofangtiao.vue"),
  },
  {
    path: "/playList",
    name: "playList",
    props: true,
    component: () => import("../views/PlayList.vue"),
    meta: {
      title: "歌单列表",
    },
    children: [
      {
        path: ":?cat",
        props: true,
        component: () => import("../views/PlayList.vue"),
      },
      // {
      //   path: '?cat=流行',
      //   component: () => import('../views/PlayList.vue')
      // },
      // {
      //   path: '?cat=摇滚',
      //   component: () => import('../views/PlayList.vue')
      // },
      // {
      //   path: '?cat=民谣',
      //   component: () => import('../views/PlayList.vue')
      // },
      // {
      //   path: '?cat=电子',
      //   component: () => import('../views/PlayList.vue')
      // }
    ],
  },
  {
    path: "/",
    name: "index",
    component: () => import("../views/Index.vue"),
  },

  {
    path: "/footerMusic",
    name: "footermusic",
    component: () => import("../views/FooterMusic.vue"),
    meta: {
      title: "音乐播放",
      hideFooter: true,
    },
  },
  {
    path: "/logUserIdea",
    name: "wnlogUserIdea",
    component: () => import("../views/WnLogUserIdea.vue"),
    meta: {
      title: "登录问卷",
      hideHeader: true,
    },
  },
  {
    path: "/regUserIdea",
    name: "wnregUserIdea",
    component: () => import("../views/WnRegUserIdea.vue"),
    meta: {
      title: "注册问卷",
      hideHeader: true,
    },
  },
  {
    path: "/register",
    name: "wnregister",
    component: () => import("../views/WnRegister.vue"),
    meta: {
      title: "注册",
      hideHeader: true,
    },
  },
  {
    path: "/login",
    name: "wnlogin",
    component: () => import("../views/WnLogin.vue"),
    meta: {
      title: "登录",
      hideHeader: true,
    },
  },
  // {
  //   path: "/home",
  //   name: "home",
  //   component: () => import("./HomeView.vue"),
  // },
  {
    path: "/about",
    name: "about",
    // route level code-splitting
    // this generates a separate chunk (about.[hash].js) for this route
    // which is lazy-loaded when the route is visited.
    component: () =>
      import(/* webpackChunkName: "about" */ "../views/AboutView.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err);
};

export default router;
